package com.caption.process;

import com.caption.core.process.BaseProcess;
import com.caption.core.result.TCRequest;
import com.caption.core.result.TCResponse;
import com.caption.entity.UserInfo;
import com.caption.mapper.UserInfoMapper;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;

/**
 * 自定义多线程处理任务
 */
@Service
public class NotificationProcess extends BaseProcess {

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public TCResponse process(TCRequest request) throws Exception {
        UserInfo condition =new UserInfo();
        BeanUtils.populate(condition,(Map)request.getData());
        if(condition.getId()==2){
            throw new RuntimeException("运行时异常");
        }
        UserInfo userInfo = userInfoMapper.findById(condition.getId());
        return new TCResponse(request.getInterfaceId(), request.getSerialNo(), 0, "成功", userInfo);
    }
}
